package com.infore.siteManagement.service;

import org.springframework.stereotype.Component;

import com.infore.siteManagement.dto.StationYunlInfoDto;
import com.infore.siteManagement.entity.Area;
import com.infore.siteManagement.entity.Basinn;
import com.infore.siteManagement.entity.Station;

@Component
public class EntityObjectMapper {

    public StationYunlInfoDto station2InfoDto(Station station) {
        StationYunlInfoDto info = new StationYunlInfoDto();
        info.setStationId(station.getStationId());
        info.setStationName(station.getStationName());
        info.setControlorLevel(station.getControlLevel() == null ?null :station.getControlLevel().toString());
        info.setStationCode(station.getStationMn());
        info.setStationAddress(station.getStationAddress());
        info.setLatitude(station.getLatitude());
        info.setLongitude(station.getLongitude());
        info.setStationClassify(station.getStationClassify() == null ? null :station.getStationClassify().getStationClassifyId());
        Area area = station.getArea();
        if(area != null) {
            info.setAreaId(area.getAreaId());
            info.setAreaName(area.getAreaName());
        }
        Basinn basinn = station.getBasinn();
        if(basinn != null) {
            info.setBasinId(basinn.getBasinnId());
            info.setBasinName(basinn.getBasinnName());
        }
        info.setStationType(station.getStationType() == null ? null :station.getStationType().getStationTypeId());
        
        return info;
    }
    
}
